import { app } from "../app";
import { getKlineTrendsByCode, saveKlineTrend } from "../dao/klineTrend";



const klineTrendRouter = () => {
    app.post("/klineTrend/save", async (req, res: any) => {
        const success = await saveKlineTrend(req.body);
        return res.json({
            code: success ? 200 : 500,
            message: success ? "保存成功" : "保存失败",
        });
    });

    

    app.get("/klineTrend/get/:code", async (req, res: any) => {
        const { code } = req.params;
        const klineTrends = await getKlineTrendsByCode(code);
        return res.json({
            code: 200,
            message: "获取成功",
            data: klineTrends,
        });
    });
};

export default klineTrendRouter;